<template>
	<view>
		<u-navbar :is-back="false" :border-bottom="false">
			<view class="u-flex u-row-between u-flex-1 u-p-x-30">
				<view>
					<text class="u-font-38 text-bold">个人中心</text>
				</view>
				<!-- <navigator url="/pages/search/search" hover-class="none">
					<u-icon name="search" size="34"></u-icon>
				</navigator> -->
				
			</view>
		</u-navbar>
		<navigator url="/pages/my/archive/archive" class="head">
			<u-avatar :src="userInfo.saveAvatar||userInfo.avatarUrl" size="130" mode="square"></u-avatar>
			<view class="info">
				<text class="u-font-34 text-bold">{{userInfo.userName}}</text>
				<view class="u-flex u-row-between">
					<text class="u-font-28 text-gray">用户号：{{userInfo.userNum}}</text>
					<view class="u-flex">
						<text class="cuIcon-qrcode"></text>
						<text class="u-m-l-10 iconfont icon-arrow-right u-font-28 text-gray"></text>
					</view>
					
				</view>
			</view>
		</navigator>
		<!-- <navigator v-if="!examine" url="/pages/wallet/wallet" class="group u-m-t-20 u-border-bottom">
			<view class="icon"><u-icon size="50" color="#f37b1d" name="rmb-circle"></u-icon></view>
			<view class="label u-font-30">我的钱包</view>
			<text class="u-m-l-10 iconfont icon-arrow-right u-font-28 text-gray"></text>
		</navigator>
		<u-gap height="20" bg-color="#F5F5F5"></u-gap> -->
		<!-- 
		<navigator url="/pages/certificate/personal" class="group u-border-bottom">
			<view class="icon">
				<text class="iconfont icon-archive u-font-50" style="color: #999;"></text>
			</view>
			<view class="label u-font-30">实名认证</view>
			<text class="u-m-l-10 iconfont icon-arrow-right u-font-28 text-gray"></text>  -->
		<!-- </navigator> -->
<!-- 		<view url="" hover-class="none" class="group u-border-bottom" @click="share(data.dictValue)">
			<view class="label u-font-28">
			<u-icon name="share" size="32" color="#555"></u-icon>
				<text style="margin-left: 16rpx;">{{data.dictLabel}}</text>
			</view>
			<view class="arrow">
				<u-icon size="28" color="#999" name="arrow-right"></u-icon>
			</view>
		</view> -->
		<!-- <view  class="group u-border-bottom" @click="huohu(data)">
			<view class="icon">
				<image :src="data.cssClass" mode="widthFix" style="width: 26px;" ></image>
	
				</view>
			<view class="label u-font-30">{{data.dictLabel}}</view>
			<text class="u-m-l-10 iconfont icon-arrow-right u-font-28 text-gray"></text>
		</view> -->
		<navigator url="/pages/face/my" class="group u-border-bottom">
			<view class="icon">
				<text class="cuIcon-emoji u-font-50" :style="{color:'#fbbd08'}"></text>
				<!-- <u-icon size="50" color="#999" name="rmb-circle"></u-icon> -->
				</view>
			<view class="label u-font-30">表情管理</view>
			<text class="u-m-l-10 iconfont icon-arrow-right u-font-28 text-gray"></text>
		</navigator>
		<!-- <navigator url="/pages/moment/moment" class="group u-border-bottom">
			<view class="icon">
				<image src="/static/images/pyq.png" mode="widthFix" style="width: 26px;" ></image>
			</view>
			<view class="label u-font-30">朋友圈</view>
			<text class="u-m-l-10 iconfont icon-arrow-right u-font-28 text-gray"></text>
		</navigator> -->
		<navigator url="/pages/setting/setting" class="group u-m-t-20">
			<view class="icon"><u-icon size="50" color="#0081ff" name="setting"></u-icon></view>
			<view class="label u-font-30">设置</view>
			<text class="u-m-l-10 iconfont icon-arrow-right u-font-28 text-gray"></text>
		</navigator>
		<view class="u-p-30 bg-white u-m-t-20 u-text-center u-font-30" @tap="logoutP">
			退出登录
		</view>
		<u-modal v-model="ask.show" :content="ask.content" @confirm="resolve" @cancel="reject" :cancel-text="ask.cancel" :confirm-color="ask.confirmColor" :confirm-text="ask.confirm" :mask-close-able="ask.maskClose" :show-title="false" show-cancel-button></u-modal>
		<view v-show="false">
			{{unread}}
		</view>
		<!-- #ifdef APP-PLUS -->
		<updatepage ref="updatepage"/>
		<!-- #endif -->
	</view>
</template>

<script>
	// #ifdef APP-PLUS
	import updatepage from "@/components/updatepage.vue"
	// #endif
	import {mapGetters,mapActions} from "vuex"
	import {toast,delay} from "@/utils/util.js"
    import {getDict} from "@/api/system.js"
	import {refreshUserInfo} from "@/api/user.js"
	export default {
		components:{
			// #ifdef APP-PLUS
			updatepage
			// #endif
		},
		data() {
			return {
                data:{},
				ask:{
					show:false,
					content:'确认退出吗?',
					confirm:'确认',
					confirmColor:'#FF0000',
					cancel:'点错了',
					maskClose:true
				},
				bridge:null
			};
		},
		computed:{
			...mapGetters('user',['userInfo']),
			...mapGetters('chat',['unread']),
			...mapGetters('system',['examine'])
		},
		onReady() {
			// #ifdef APP-PLUS
			const upRef = this.$refs.updatepage
			upRef.check().then(({needUp,lastVersion})=>{
				console.log(needUp,lastVersion)
				if(!needUp){
					return
				}
				upRef.upgrade();
				if(lastVersion.updateType==2){
					upRef.upgradeEvent()
				}
			})
			// #endif
		},
	async	onShow() {
			this.show();
       
		},
		async onPullDownRefresh() {
			try{
				await this.pullDownRefresh()
			}finally{
				uni.stopPullDownRefresh()
			}
		},
      async  mounted() {
            // const res=await 	getDict('huohu');
            // this.data=res[0];
            // console.log(this.data)
        },
		methods:{
			
	huohu(item){
		console.log(item.dictValue)
		const url =item.dictValue
		if(item.isDefault=='Y'){
			plus.runtime.openURL(url);
		}
		else{
			uni.navigateTo({
				url:'/pages/find/webview?url='+url
			})
			
		}
	
	},
			show(){
				refreshUserInfo().then(this.fetchUserInfo)
				this.fetchAssets()
			},
			async pullDownRefresh(){
				await refreshUserInfo().then(this.fetchUserInfo)
				this.fetchAssets()
			},
			pageScroll(e){
			},
			
			...mapActions('user',['logout','fetchUserInfo']),
			...mapActions('wallet',['fetchAssets']),
			reject(e){
				this.bridge&&this.bridge.reject&&this.bridge.reject(e)
			},
			resolve(e){
				this.bridge&&this.bridge.resolve&&this.bridge.resolve(e)
			},
			async logoutP(){
				await new Promise((resolve, reject) => {
					this.ask.show =true
					this.bridge = {
						resolve,
						reject
					}
				})
				await this.logout()
				toast('登出成功')
				await delay(1000)
				uni.reLaunch({
					url:'/pages/login/login'
				})
			}
		}
		
	}
</script>
<style lang="scss" scoped>
	.head{
		display: flex;
		padding: 60rpx 30rpx 50rpx;
		background-color: #FFFFFF;
		.info{
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			margin-left: 20rpx;
			flex: 1;
			padding: 6rpx 0;
		}
	}
	.group{
		display: flex;
		align-items: center;
		padding: 30rpx 30rpx;
		background-color: #FFFFFF;
		.icon{
			display: flex;
		}
		.label{
			flex: 1;
			margin: 0 20rpx;
		}
	}
</style> 
